<html>
<body>

<?php

//Syntax for cookies:setcookie(name, value, expire, path, domain);

$expire=time()+60*60*24*30;
setcookie("user", "Alex Porter", $expire);

?>

//Retrieve a cookie value

<?php
// Print a cookie
echo $_COOKIE["user"];

// A way to view all cookies
print_r($_COOKIE);
?>


// isset() function to find out if a cookie has been set:


<?php
if (isset($_COOKIE["user"]))
  echo "Welcome " . $_COOKIE["user"] . "!<br />";
else
  echo "Welcome guest!<br />";
?>


//How to Delete a Cookie?

<?php
// set the expiration date to one hour ago
setcookie("user", "", time()-3600);
?>


</body>
</html>